<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>评分组件</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
</head>
<body>
<img th:src="@{/images/lastImg.png}" width="700" height="300">
<span>您的鼓励，就是我们的动力！请为当前骑手打分哦！</span>
<div id="test1"></div>
<script th:src="@{/js/jquery-3.5.1.js}" type="text/javascript"></script>
<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script>
    layui.use('rate', function () {
        var rate = layui.rate;
        var orderId = sessionStorage.getItem("orderId")
        //渲染
        var ins1 = rate.render({
            elem: '#test1'  //绑定元素
            , choose: function (value) {
                $.post("/comment/add"
                    , {orderId: orderId, score: value}
                    , function (data) {
                        if (data.code == 200) {
                            parent.layer.close(parent.layer.index);
                            console.log(this)
                        } else if (data.code == 500) {
                            layer.msg('提交失败');
                        } else {
                            layer.msg('系统繁忙，请稍后再试');
                        }
                    })


            }
        });
    });
</script>
</body>
</html>